from flask import Flask, Blueprint, render_template,redirect
from config import db
from models import User,House;


# 创建蓝图，蓝图名称为index_page
user_page = Blueprint('user_page', __name__)

# 定义首页路由
@user_page.route('/user/<name>')
def index(name):
    # 查询用户
    user = User.query.filter(User.name == name).first()
    if user:

            
        # 默认渲染首页模板
        return render_template('user.html', user=user)
    else:
        #不存在则跳转回首页
        return redirect('/')